package com.wnxy.controller;


import com.wnxy.annotation.Validate;
import com.wnxy.dto.DeleteDto;
import com.wnxy.dto.Result;
import com.wnxy.dto.SeatDto;
import com.wnxy.dto.StatusCode;
import com.wnxy.service.SeatService;
import com.wnxy.vo.SeatVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author alice
 * @since 2021-10-25
 */
@RestController
@RequestMapping("/seat")
public class SeatController {
    @Autowired
    private SeatService seatService;
    @GetMapping("/find")
    public Result getSeatByRoom( Integer roomId){
        System.out.println(roomId);
       List<SeatDto> seatDtos=seatService.seatList(roomId);
        return Result.getInstance().setFlag(true)
                .setStatusCode(StatusCode.SUCCESS.getCode())
                .setMessage("查询成功").setData(seatDtos);
    }

    @GetMapping("/find1")
    public Result getSeatByperform( Integer performId){
        System.out.println(performId);
        List<SeatDto> seatDtos=seatService.seatListByPerform(performId);
        return Result.getInstance().setFlag(true)
                .setStatusCode(StatusCode.SUCCESS.getCode())
                .setMessage("查询成功").setData(seatDtos);
    }
    @GetMapping("/findByPerform")
    public Result getSeatByPerform( Integer performId){
        System.out.println(performId);
        List<SeatDto> seatDtos=seatService.seatsByPerform(performId);
        return Result.getInstance().setFlag(true)
                .setStatusCode(StatusCode.SUCCESS.getCode())
                .setMessage("查询成功").setData(seatDtos);
    }
//    @Validate
    @PostMapping("/ban")
    public Result banSeat(@RequestBody SeatVo seatVo){
        DeleteDto deleteDto = seatService.banSeat(seatVo);
        return Result.getInstance().setFlag(true).setStatusCode(StatusCode.SUCCESS.getCode())
                .setMessage("状态改变成功").setData(deleteDto);
    }
//    @Validate
    @PostMapping("/up")
    public Result upSeat(@RequestBody SeatVo seatVo){
        DeleteDto deleteDto = seatService.upSeat(seatVo);
        return Result.getInstance().setFlag(true).setStatusCode(StatusCode.SUCCESS.getCode())
                .setMessage("状态改变成功").setData(deleteDto);
    }
}

